<template>
  <div class="credit-life-container dark-theme">
    <!-- 轮播图部分 -->
    <div class="carousel-section">
      <el-carousel :interval="4000" type="card" height="400px">
        <el-carousel-item v-for="(item, index) in carouselItems" :key="index">
          <div class="carousel-content" @click="handleServiceClick(item.route)">
            <img :src="item.image" :alt="item.title" class="carousel-image">
            <div class="carousel-info">
              <h2>{{ item.title }}</h2>
              <p>{{ item.description }}</p>
            </div>
          </div>
        </el-carousel-item>
      </el-carousel>
    </div>

    <!-- 亲社会活动展示区域 -->
    <div class="behavior-section">
      <h2 class="section-title">亲社会活动</h2>
      <div class="behavior-grid">
        <div v-for="(activity, index) in behaviorActivities" 
             :key="index" 
             class="behavior-card"
             @click="handleActivityClick(activity.route)">
          <img :src="activity.image" :alt="activity.title" class="activity-image">
          <div class="activity-info">
            <h3>{{ activity.title }}</h3>
            <p>{{ activity.description }}</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'CreditLife',
  data() {
    return {
      carouselItems: [
        {
          title: '便捷泊车',
          description: '信用停车，智慧出行',
          image: require('@/views/imgs/parking.jpg'),
          route: '/credit-life/parking'
        },
        {
          title: '舒心就医',
          description: '信用就医，便捷服务',
          image: require('@/views/imgs/medical.jpg'),
          route: '/credit-life/medical'
        },
        {
          title: '图书借阅',
          description: '信用借阅，知识共享',
          image: require('@/views/imgs/library.jpg'),
          route: '/credit-life/library'
        },
        {
          title: '信用出行',
          description: '信用出行，绿色生活',
          image: require('@/views/imgs/travel.jpg'),
          route: '/credit-life/travel'
        }
      ],
      behaviorActivities: [
        {
          title: '志愿服务',
          description: '参与社区志愿服务，共建美好家园',
          image: require('@/views/imgs/volunteer.jpg'),
          route: '/behavior/volunteer'
        },
        {
          title: '环保行动',
          description: '践行环保理念，守护绿色地球',
          image: require('@/views/imgs/environment.jpg'),
          route: '/behavior/environment'
        },
        {
          title: '公益捐赠',
          description: '爱心捐赠，传递温暖',
          image: require('@/views/imgs/donation.jpg'),
          route: '/behavior/donation'
        },
        {
          title: '社区互助',
          description: '邻里互助，共建和谐社区',
          image: require('@/views/imgs/community.jpg'),
          route: '/behavior/community'
        }
      ]
    }
  },
  methods: {
    handleServiceClick(route) {
      this.$router.push(route)
    },
    handleActivityClick(route) {
      this.$router.push(route)
    }
  }
}
</script>

<style scoped>
.credit-life-container {
  min-height: 100vh;
  background: radial-gradient(ellipse at center, #001e3c 0%, #000 100%);
  padding: 20px;
  color: #fff;
}

.carousel-section {
  margin-bottom: 40px;
}

.carousel-content {
  height: 100%;
  position: relative;
  cursor: pointer;
  border-radius: 8px;
  overflow: hidden;
}

.carousel-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.carousel-content:hover .carousel-image {
  transform: scale(1.05);
}

.carousel-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
}

.carousel-info h2 {
  margin: 0;
  font-size: 24px;
  color: #4fc3f7;
}

.carousel-info p {
  margin: 10px 0 0;
  font-size: 16px;
  color: #fff;
}

.section-title {
  text-align: center;
  color: #4fc3f7;
  margin-bottom: 30px;
  font-size: 28px;
}

.behavior-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  padding: 0 20px;
}

.behavior-card {
  background: #003b64;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.behavior-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(79, 195, 247, 0.3);
}

.activity-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.activity-info {
  padding: 15px;
}

.activity-info h3 {
  margin: 0;
  color: #4fc3f7;
  font-size: 18px;
}

.activity-info p {
  margin: 10px 0 0;
  color: #b0bec5;
  font-size: 14px;
  line-height: 1.4;
}

/* 响应式调整 */
@media (max-width: 768px) {
  .behavior-grid {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  }
  
  .carousel-info h2 {
    font-size: 20px;
  }
  
  .carousel-info p {
    font-size: 14px;
  }
}
</style> 